package today.rocky.boot.kafka.consumer.config;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

import java.util.Optional;

/**
 * @author Rocky
 * @version 1.0
 * @date 2020/3/18 16:56
 */
@Component
public class ConsumeConfig {

    @KafkaListener(topics = {"test"})
    public  void onListen(ConsumerRecord record, Acknowledgment ack){
        Optional<?> value = Optional.ofNullable(record.value());
        if (value.isPresent()){
            System.out.println(value.get());
        }
        ack.acknowledge();
    }


}
